package epucjr.psicopuc.dominio;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import org.hibernate.search.annotations.ContainedIn;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
@Entity
@Indexed
public class ExperienciaProfissional {
	
	
	/************************
	 * ATRIBUTOS
	 ***********************/
	@Id
	@DocumentId
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private long idExperienciaProfissional;
	
	@Field
	private String possuiExperiencia;
	
	@OneToMany(fetch = FetchType.LAZY , cascade = CascadeType.ALL)
	@JoinColumn
	private List<Empresa> empresas;
	
	
	@ContainedIn
	@OneToOne(mappedBy="experienciasProfissional")	
	private Curriculo curriculo;
	
	/************************
	 * CONSTRUTOR
	 ***********************/
	
	public ExperienciaProfissional() {
		this.empresas = new ArrayList<Empresa>();
	}
	
	public ExperienciaProfissional(List<Empresa> empresa, String possuiExperiencia) {
		this.setEmpresas(empresa);
		this.setPossuiExperiencia(possuiExperiencia);
	}
	
	
	public void adicionarEmpresa(Empresa empresa){
		this.getEmpresas().add(empresa);
	}

	/************************
	 * GETTERS/SETTERS
	 ***********************/

	public long getIdExperienciaProfissional() {
		return idExperienciaProfissional;
	}
	public void setIdExperienciaProfissional(long idExperienciaProfissional) {
		this.idExperienciaProfissional = idExperienciaProfissional;
	}

	public List<Empresa> getEmpresas() {
		return empresas;
	}

	public void setEmpresas(List<Empresa> empresas) {
		this.empresas = empresas;
	}

	public String getPossuiExperiencia() {
		return possuiExperiencia;
	}

	public void setPossuiExperiencia(String possuiExperiencia) {
		this.possuiExperiencia = possuiExperiencia;
	}

	public Curriculo getCurriculo() {
		return curriculo;
	}

	public void setCurriculo(Curriculo curriculo) {
		this.curriculo = curriculo;
	} 
	
	
}
